1. /* sfmfput.cpp by K.Tsuru */
  2. // function ID = 740 DARDIX
  3. /**************************
  4. SFraction class
  5. It provides the output.
  6. **************************/
  7. #ifndef SN_H
  8. #include "sn.h"
  9. #endif
  10. ///////////////////////////////////////
  11. // declared as long Put(long fig=5, char delmt=' ', int fmt = BRACKET); in "sfract.h"
  12. int SFraction::lineFormat = SFraction::BRACKET; // Set by BRACKET | END_CR | MID_CR. Set "BRACKET" in default
  13. long SFraction::ioCount = 0;
  14. void SFraction::SetFormat(int fmt) { // The format of Num() and Den() obey that of SLong.
  15. lineFormat = fmt;
  16. }
  17. long SFraction::Put(int fmt) {
  18. lineFormat = fmt; ioCount = 0;
  19. Reduce();
  20. long p = 0;
  21. if(lineFormat & BRACKET){
  22. num.FPutc('('); p = 2; // ()
  23. }
  24. // in SLong class long Put(long fig=5, int perLine = 0, int lineFormat = CRLF, int delmt=' ') const; // 261
  25. if( den.IsOne() ){ //denominator=1
  26. p += num.Put(num.figUnit, num.perLine, num.lineFormat, num.delmt);
  27. } else {
  28. p += num.Put(num.figUnit, num.perLine, num.lineFormat, num.delmt);
  29. num.FPutc('/'); p++;
  30. if(lineFormat & MID_CR) { num.FPutc('\n'); p++; }
  31. p += den.Put(num.figUnit, num.perLine, num.lineFormat, num.delmt);
  32. }
  33. if(lineFormat & BRACKET) {
  34. num.FPutc(')'); p++;
  35. }
  36. if(lineFormat & END_CR) {
  37. num.FPutc('\n'); p++;
  38. }
  39. return ioCount = p;
  40. }

sfmfput.cpp : last modifiled at 2017/10/23 11:02:13(1,281 bytes)
created at 2015/12/22 16:07:29
The creation time of this html file is 2017/10/23 11:26:54 (Mon Oct 23 11:26:54 2017).